Skip to content

Add "booting" flag and emit "booted" event - #77

Merged
bajtos merged 1 commit into
masterfrom
feature/add-boot-completion-check
Jan 7, 2015
Merged

Add "booting" flag and emit "booted" event#77
bajtos merged 1 commit into
masterfrom
feature/add-boot-completion-check

Conversation

@superkhau

Copy link
Copy Markdown
Contributor

Comment thread lib/executor.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app.booting should be reset before calling callback(err).

@bajtos

bajtos commented Dec 3, 2014

Copy link
Copy Markdown
Member

The implementation looks mostly good. Please add a unit-test exercising both sync and async case.

@superkhau
superkhau force-pushed the feature/add-boot-completion-check branch from 9f97660 to c9d0f93 Compare December 4, 2014 07:21
@superkhau
superkhau force-pushed the feature/add-boot-completion-check branch from c9d0f93 to 2bb1157 Compare December 14, 2014 02:18
@superkhau
superkhau force-pushed the feature/add-boot-completion-check branch 3 times, most recently from 7674fbf to 9ef20f5 Compare January 1, 2015 02:19
@superkhau

Copy link
Copy Markdown
Contributor Author

@bajtos Added unit tests, reassigning to you for review.

@superkhau superkhau assigned bajtos and unassigned superkhau Jan 1, 2015
Comment thread test/executor.test.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use .to.be.undefined() to prevent jshint warnings.

$ npm test

> loopback-boot@2.5.2 pretest /Users/bajtos/src/loopback/boot
> jscs . && jshint .

No code style errors found.
test/executor.test.js: line 57, col 33, Expected an assignment or function call and instead saw an expression.
test/executor.test.js: line 59, col 27, Expected an assignment or function call and instead saw an expression.
test/executor.test.js: line 60, col 35, Expected an assignment or function call and instead saw an expression.
test/executor.test.js: line 67, col 28, Expected an assignment or function call and instead saw an expression.
test/executor.test.js: line 71, col 27, Expected an assignment or function call and instead saw an expression.
test/executor.test.js: line 77, col 27, Expected an assignment or function call and instead saw an expression.

6 errors
npm ERR! Test failed.  See above for more details.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't see this because I ran mocha instead of npm test. Fixed.

@bajtos

bajtos commented Jan 5, 2015

Copy link
Copy Markdown
Member

see my comments above.

@bajtos bajtos assigned superkhau and unassigned bajtos Jan 5, 2015
@superkhau

Copy link
Copy Markdown
Contributor Author

@bajtos Review again please. 196d192

@superkhau superkhau assigned bajtos and unassigned superkhau Jan 5, 2015
Comment thread test/executor.test.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion never fails, please remove.

If you feel a test without an assertion is confusing, then add a comment at L67 explaining that the test fails on timeout when the event is not emitted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@bajtos

bajtos commented Jan 6, 2015

Copy link
Copy Markdown
Member

There is no test checking that app.booting is actually set to true, but I suppose I can live with that.

Please fix the comment on L67 above and squash all commits into a single one. Other than that, the patch LGTM.

@bajtos bajtos assigned superkhau and unassigned bajtos Jan 6, 2015
@superkhau

Copy link
Copy Markdown
Contributor Author

I wanted to add a test for app.booting = true, but I had no idea how to test it in the middle of the function execution. I'm all ears if you have a good technique to do that.

@superkhau
superkhau force-pushed the feature/add-boot-completion-check branch from 196d192 to df0d8b1 Compare January 7, 2015 05:23
@superkhau

Copy link
Copy Markdown
Contributor Author

@bajtos Updated with latest comments. Please review again before merge.

@superkhau superkhau assigned bajtos and unassigned superkhau Jan 7, 2015
@superkhau
superkhau force-pushed the feature/add-boot-completion-check branch from df0d8b1 to 1f7d8e5 Compare January 7, 2015 05:27
bajtos added a commit that referenced this pull request Jan 7, 2015
@bajtos
bajtos merged commit c47bde9 into master Jan 7, 2015
@bajtos bajtos removed the #review label Jan 7, 2015
@bajtos

bajtos commented Jan 7, 2015

Copy link
Copy Markdown
Member

Landed, thank you. I'll make a new npmjs release a bit later, once I have all pieces related to #86 in place.

@bajtos

bajtos commented Jan 7, 2015

Copy link
Copy Markdown
Member

I wanted to add a test for app.booting = true, but I had no idea how to test it in the middle of the function execution. I'm all ears if you have a good technique to do that.

Add a boot script asserting on the flag.

// boot/set-app-is-booting.js
module.exports = function(app) {
  app.wasBootingInBootScript = app.booting;
}

Then run boot(app, appdir) and check that app.wasBootingInBootScript was set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants